#include <aos/aos.h>
#include "aos/cli.h"
#include "anv_testsuite.h"
#include <pthread.h>

ANV_TESTSUITE_FIXTURE(test_group_1_fixture_1)
{
    int a = 10;
    expect(a == 10);
    
    int b = 13;
    expect(a == b);
}

ANV_TESTSUITE_FIXTURE(test_group_1_fixture_2)
{

}

ANV_TESTSUITE_FIXTURE(test_group_1_fixture_3)
{
    expect_msg(0, "rip");
}

ANV_TESTSUITE(test_group_1,
    ANV_TESTSUITE_ADD(test_group_1_fixture_1),
    ANV_TESTSUITE_ADD(test_group_1_fixture_2),
    ANV_TESTSUITE_ADD(test_group_1_fixture_3),
);

ANV_TESTSUITE_FIXTURE(test_group_2_fixture_1)
{

}

ANV_TESTSUITE(test_group_2,
    ANV_TESTSUITE_ADD(test_group_2_fixture_1),
);

static void * anv_testsuit_thread(void *arg)
{
    ANV_TESTSUITE_BEGIN(stdout);    // optional
    ANV_TESTSUITE_RUN(test_group_1, stdout);
    ANV_TESTSUITE_RUN(test_group_2, stdout);
    ANV_TESTSUITE_END(stdout);      // optional
	return 0;
}
int yoc_anv_testsuit_example(int argc, char *argv[])
{
    int ret = 0;
    int thread_para;
    pthread_t new_thread;
    pthread_attr_t attr;
    int *retval;

    thread_para = 10;
    pthread_attr_init(&attr);
    pthread_attr_setstacksize(&attr, 4096);
    ret = pthread_create(&new_thread, &attr, anv_testsuit_thread, &thread_para);
    if (ret != 0) {
        printf("pthread_create failed, ret:%d\n", ret);
        pthread_attr_destroy(&attr);
        return -1;
    }
    return 0;
}
ALIOS_CLI_CMD_REGISTER(yoc_anv_testsuit_example,yoc_anv_testsuit_example, anv testsuit example);
